import http from "@/utils/ajax/http";
import { extend } from "@/utils/extend";

const api = {
    code: {
        OK: 0,
    },
    user: {
        login: "authLogin.do?ac=login",
        tokenLogin: "tokenLogin.do",
        logout: "logout.do",
    },
    checkUpdate: "sh.do",
    editorPassword: "editPassword",
    checkField: "checkno.do",
    dbQuery: "/db/query",
    dbSelect: "/db/select",

    payment: "payment.do",

    captch() {
        var url = "captcha.do?rd=" + Math.floor(Math.random() * 100000);
        return new Promise((resolve, reject) => {
            http.get(url).then((res) => {
                var url = res.data;
                resolve(url);
            }, reject);
        });
    },
    search: {
        select: "selectUpdateSearch.do",
        table: "tableAjax.do?a=table",
        selectView: "selectView.do",
        all: "selectAll.do",
    },
    attachment: {
        uploadUrl: "upload_re.do",
        upload(file) {
            return new Promise((resolve, reject) => {
                var formdata = new FormData();
                formdata.append("fujian", file, file.name || "tmp.png");
                http.post(api.attachment.uploadUrl, formdata)
                    .then((res) => {
                        if (res.code == api.code.OK) {
                            resolve(res.data);
                        } else {
                            reject(res.msg);
                        }
                    })
                    .catch((err) => {
                        reject(err.message);
                    });
            });
        },
    },
    admins: {
        list: "admins_list.do",
        insert: "adminsinsert.do",
        update: "adminsupdate.do",
        delete: "admins_delete.do",
        detail: "admins_detail.do",
        create: "admins_add.do",
        edit: "admins_updt.do",
    },
    yonghu: {
        list: "yonghu_list.do",
        insert: "yonghuinsert.do",
        update: "yonghuupdate.do",
        delete: "yonghu_delete.do",
        detail: "yonghu_detail.do",
        create: "yonghu_add.do",
        edit: "yonghu_updt.do",
    },
    xinwenfenlei: {
        list: "xinwenfenlei_list.do",
        insert: "xinwenfenleiinsert.do",
        update: "xinwenfenleiupdate.do",
        delete: "xinwenfenlei_delete.do",
        detail: "xinwenfenlei_detail.do",
        create: "xinwenfenlei_add.do",
        edit: "xinwenfenlei_updt.do",
    },
    xinwenxinxi: {
        list: "xinwenxinxi_list.do",
        insert: "xinwenxinxiinsert.do",
        update: "xinwenxinxiupdate.do",
        delete: "xinwenxinxi_delete.do",
        detail: "xinwenxinxi_detail.do",
        create: "xinwenxinxi_add.do",
        edit: "xinwenxinxi_updt.do",
        listtianjiaren: "xinwenxinxi_list_tianjiaren.do",
        weblist: "xinwenxinxilist.do",
        webdetail: "xinwenxinxidetail.do",
    },
    liuyanban: {
        list: "liuyanban_list.do",
        insert: "liuyanbaninsert.do",
        update: "liuyanbanupdate.do",
        delete: "liuyanban_delete.do",
        detail: "liuyanban_detail.do",
        create: "liuyanban_add.do",
        edit: "liuyanban_updt.do",
        listliuyanren: "liuyanban_list_liuyanren.do",
        weblist: "liuyanbanlist.do",
    },
    lunbotu: {
        list: "lunbotu_list.do",
        insert: "lunbotuinsert.do",
        update: "lunbotuupdate.do",
        delete: "lunbotu_delete.do",
        detail: "lunbotu_detail.do",
        create: "lunbotu_add.do",
        edit: "lunbotu_updt.do",
    },
    pinglun: {
        list: "pinglun_list.do",
        insert: "pingluninsert.do",
        update: "pinglunupdate.do",
        delete: "pinglun_delete.do",
        detail: "pinglun_detail.do",
        create: "pinglun_add.do",
        edit: "pinglun_updt.do",
        listpinglunren: "pinglun_list_pinglunren.do",
    },
    shoucang: {
        list: "shoucang_list.do",
        insert: "shoucanginsert.do",
        update: "shoucangupdate.do",
        delete: "shoucang_delete.do",
        detail: "shoucang_detail.do",
        create: "shoucang_add.do",
        edit: "shoucang_updt.do",
        listusername: "shoucang_list_username.do",
        batch: "shoucang_batch.do",
    },
    youxifenlei: {
        list: "youxifenlei_list.do",
        insert: "youxifenleiinsert.do",
        update: "youxifenleiupdate.do",
        delete: "youxifenlei_delete.do",
        detail: "youxifenlei_detail.do",
        create: "youxifenlei_add.do",
        edit: "youxifenlei_updt.do",
    },
    shangpinxinxi: {
        list: "shangpinxinxi_list.do",
        insert: "shangpinxinxiinsert.do",
        update: "shangpinxinxiupdate.do",
        delete: "shangpinxinxi_delete.do",
        detail: "shangpinxinxi_detail.do",
        create: "shangpinxinxi_add.do",
        edit: "shangpinxinxi_updt.do",
        listfaburen: "shangpinxinxi_list_faburen.do",
        weblist: "shangpinxinxilist.do",
        webdetail: "shangpinxinxidetail.do",
    },
    youxixinxi: {
        list: "youxixinxi_list.do",
        insert: "youxixinxiinsert.do",
        update: "youxixinxiupdate.do",
        delete: "youxixinxi_delete.do",
        detail: "youxixinxi_detail.do",
        create: "youxixinxi_add.do",
        edit: "youxixinxi_updt.do",
        weblist: "youxixinxilist.do",
        webdetail: "youxixinxidetail.do",
    },
    changshangxinxi: {
        list: "changshangxinxi_list.do",
        insert: "changshangxinxiinsert.do",
        update: "changshangxinxiupdate.do",
        delete: "changshangxinxi_delete.do",
        detail: "changshangxinxi_detail.do",
        create: "changshangxinxi_add.do",
        edit: "changshangxinxi_updt.do",
    },
    gouwuche: {
        list: "gouwuche_list.do",
        insert: "gouwucheinsert.do",
        update: "gouwucheupdate.do",
        delete: "gouwuche_delete.do",
        detail: "gouwuche_detail.do",
        create: "gouwuche_add.do",
        edit: "gouwuche_updt.do",
        listgoumairen: "gouwuche_list_goumairen.do",
    },
    dingdanxinxi: {
        list: "dingdanxinxi_list.do",
        insert: "dingdanxinxiinsert.do",
        update: "dingdanxinxiupdate.do",
        delete: "dingdanxinxi_delete.do",
        detail: "dingdanxinxi_detail.do",
        create: "dingdanxinxi_add.do",
        edit: "dingdanxinxi_updt.do",
        listxiadanren: "dingdanxinxi_list_xiadanren.do",
    },
    dingdanxinxixuangoushangpin: {
        list: "dingdanxinxixuangoushangpin_list.do",
        insert: "dingdanxinxixuangoushangpininsert.do",
        update: "dingdanxinxixuangoushangpinupdate.do",
        delete: "dingdanxinxixuangoushangpin_delete.do",
        detail: "dingdanxinxixuangoushangpin_detail.do",
        create: "dingdanxinxixuangoushangpin_add.do",
        edit: "dingdanxinxixuangoushangpin_updt.do",
    },
    dingdanfahuo: {
        list: "dingdanfahuo_list.do",
        insert: "dingdanfahuoinsert.do",
        update: "dingdanfahuoupdate.do",
        delete: "dingdanfahuo_delete.do",
        detail: "dingdanfahuo_detail.do",
        create: "dingdanfahuo_add.do",
        edit: "dingdanfahuo_updt.do",
        listxiadanren: "dingdanfahuo_list_xiadanren.do",
        listfahuoren: "dingdanfahuo_list_fahuoren.do",
    },
    dingdanfahuoxuangoushangpin: {
        list: "dingdanfahuoxuangoushangpin_list.do",
        insert: "dingdanfahuoxuangoushangpininsert.do",
        update: "dingdanfahuoxuangoushangpinupdate.do",
        delete: "dingdanfahuoxuangoushangpin_delete.do",
        detail: "dingdanfahuoxuangoushangpin_detail.do",
        create: "dingdanfahuoxuangoushangpin_add.do",
        edit: "dingdanfahuoxuangoushangpin_updt.do",
    },
    dingdanqianshou: {
        list: "dingdanqianshou_list.do",
        insert: "dingdanqianshouinsert.do",
        update: "dingdanqianshouupdate.do",
        delete: "dingdanqianshou_delete.do",
        detail: "dingdanqianshou_detail.do",
        create: "dingdanqianshou_add.do",
        edit: "dingdanqianshou_updt.do",
        listqianshouren: "dingdanqianshou_list_qianshouren.do",
    },
    dingdanqianshouxuangoushangpin: {
        list: "dingdanqianshouxuangoushangpin_list.do",
        insert: "dingdanqianshouxuangoushangpininsert.do",
        update: "dingdanqianshouxuangoushangpinupdate.do",
        delete: "dingdanqianshouxuangoushangpin_delete.do",
        detail: "dingdanqianshouxuangoushangpin_detail.do",
        create: "dingdanqianshouxuangoushangpin_add.do",
        edit: "dingdanqianshouxuangoushangpin_updt.do",
    },
    youqinglianjie: {
        list: "youqinglianjie_list.do",
        insert: "youqinglianjieinsert.do",
        update: "youqinglianjieupdate.do",
        delete: "youqinglianjie_delete.do",
        detail: "youqinglianjie_detail.do",
        create: "youqinglianjie_add.do",
        edit: "youqinglianjie_updt.do",
    },
};

export default api;
